<?php
include '../../common.inc.php';
include 'fun.php';
$mysqli = new mysqli('localhost', 'root', '', 'test_data');
$sql = "select * from koubei_myisam2 where py='' order by id desc limit 120";

$result = $mysqli->query($sql);
$res = $result->fetch_all(MYSQLI_ASSOC);
if (!$res) exit('No More Results');
foreach ($res as $r) {
	$new = str_replace(array(' ', '&amp;', '·', '&', '&middot;'), array('_', '_', '_', '_', '_'), $r['dianming']);
	$py = gb2py2($new);

	if (!preg_match('/[a-z0-9A-Z_]{4,20}/is', $py)) {

		$file = realpath('./file/is/a.txt');
		if (strlen($py) ==0) {
			$py='___';
		}
		file_put_contents($file, file_get_contents($file)."\n".$py.'-'.$r['ID']);
		//continue;
	}

	$sql = "update koubei_myisam2 set py ='{$py}' ,dianming='{$new}' WHERE ID = {$r['ID']}";
	$mysqli->query($sql);
}
echo '<meta http-equiv="refresh" content="0; url='.$_SERVER['PHP_SELF'].'" />';
echo '<pre style="font-size:300px;">';
echo $r['ID'];

?>
